package com.deadletter.controller;

import com.deadletter.config.MqConfig;
import com.deadletter.service.MyMessagePostProcessor;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {


    @Autowired
    private RabbitTemplate rabbitTemplate;


    @RequestMapping("/test")
    public void test(@RequestParam("str") String str){

        MessagePostProcessor messagePostProcessor = new MyMessagePostProcessor(600000);

        //加个ttl
//        rabbitTemplate.convertAndSend(MqConfig.BUSINESS_EXCHANGE_NAME,"",str);

        rabbitTemplate.convertAndSend(MqConfig.BUSINESS_EXCHANGE_NAME,"",str,messagePostProcessor);
    }

}
